/* (c) 2015 JiaThis Inc. 0710*/
(function() {
    var m = document,
        t = window,
        p = parseInt,
        n = m.body,
        d = encodeURIComponent,
        q = {},
        g = navigator.userAgent.toLowerCase(),
        h = -1 != g.indexOf("opera") && opera.version(); - 1 != g.indexOf("msie") && !h && g.substr(g.indexOf("msie") + 5, 3);
    for (var c = "undefined" == typeof jiathis_config ? {} : jiathis_config, g = m.getElementsByTagName("script"), e = 0; h = g[e++];) !h.src || -1 == h.src.indexOf("jiathis_m.js") && -1 == h.src.indexOf("jiathis.com/code/jiathis_m.js") || h.src.replace(/(uid|UYUserId|style|lang|footmark)=([^&]+)/g, function(b, a, l) {
        q[a] = l
    });
    t.jiathis_mh5 = {
        creElm: function(b, a, l) {
            a = m.createElement(a || "div");
            for (var c in b) "style" == c ? a[c].cssText = b[c] : a[c] = b[c];
            return (l || n).insertBefore(a, (l || n).firstChild)
        },
        getItem: function(b, a, c, r) {
            b = b.getElementsByTagName(a);
            a = [];
            for (var f = 0, d = b.length; f < d; f += 1) b[f].className !== c || null != r && "class" != r ? b[f].id === c && "id" == r && a.push(b[f]) : a.push(b[f]);
            return a
        },
        getDes: function() {
            var b = "",
                a = m.getElementsByTagName("meta"),
                c = a.length;
            if (/msie/i.test(navigator.userAgent)) {
                for (e = 0; e < c; e++) "description" == a[e].name && (b = a[e].content);
                if ("" == b)
                    for (k in a) "description" == k && (b = a[k].content);
                /msie 6/i.test(navigator.userAgent) && (b = "")
            } else
                for (k in a) /chrome/i.test(navigator.userAgent) ? "undefined" != typeof a[k].name && "description" == a[k].name && (b = a[k].content) : "description" == k && (b = a[k].content);
            return b = b.replace(/\s/g, "")
        },
        getPic: function() {
            var b = m.getElementsByTagName("img"),
                a = "",
                c = "",
                d = [];
            for (e = 0; e < b.length; e++) {
                var d = p(b.item(e).offsetWidth),
                    f = p(b.item(e).offsetHeight),
                    g = 300 / f * 150,
                    h = 150 / d * 300;
                300 <= d && 150 <= f && 150 >= g - h && (a += c + b.item(e).src, c = ",")
            }
            d = a.split(",");
            b = p(Math.random() * d.length);
            return d[b]
        },
        sendTo: function(b) {
            var a = jiathis_mh5.getDes(),
                l = jiathis_mh5.getPic(),
                e = "?webid=" + b,
                f = "&url=" + d(String(c.url || document.location)),
                g = "&title=" + d(String(c.title || document.title)),
                a = c.summary ? "&summary=" + d(c.summary) : a ? "&summary=" + d(a) : "",
                h = q.uid ? "&uid=" + p(q.uid) : "&uid=1626433",
                m = c.data_track_clickback ? "&jtss=1" : "",
                n = c.appkey && c.appkey[b] ? "&appkey=" + c.appkey[b] : "",
                l = c.pic ? "&pic=" + d(c.pic) : l ? "&pic=" + d(l) : "";
            B = "http://s.jiathis.com/" + e + f + g + h + m + n + l + (c.ralateuid && c.ralateuid[b] ? "&ralateuid=" + c.ralateuid[b] : "") + a + (0 == c.shortUrl ? "" : "&su=1");
            window.open(B, "")
        },
        init: function() {            
            var b = jiathis_mh5.getItem(m, "span", "jiathis_style_m"),
                a = jiathis_mh5.getDes(),
                e = jiathis_mh5.getPic(),
                g = "?url=" + d(String(c.url || document.location)),
                f = "&title=" + d(String(c.title || document.title)),
                a = c.summary ? "&summary=" + d(c.summary) : a ? "&summary=" + d(a) : "",
                h = q.uid ? "&uid=" + p(q.uid) : "&uid=1626433",
                e = c.pic ? "&pic=" + d(c.pic) : e ? "&pic=" + d(e) : "",
                n;
            for (n in b) b[n].innerHTML = '<a href="http://www.jiathis.com/share' + g + f + a + h + e + '" class="icon share" target="_blank"></a>'
        }
    };
    jiathis_mh5.init()
})();